package com.treasure.infrastructure.index;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;

@Component
public class IndexDocHandleProvider {

    @Autowired
    private List<IndexDocHandler> indexDocHandlerList;

    public IndexDocHandler getInstance(IndexDocTypeEnum indexDocType) {
        if (Objects.isNull(indexDocType)) {
            return null;
        }
        for (IndexDocHandler indexDocHandler : indexDocHandlerList) {
            if (Objects.equals(indexDocHandler.getIndexDocType(), indexDocType)) {
                return indexDocHandler;
            }
        }
        return null;
    }

}
